package com.example.springdata.controller;

import com.example.springdata.entity.User;
import com.example.springdata.mapper.UserMapper;
import com.example.springdata.service.IUserService;
import com.example.springdata.vo.UserVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @description:
 * @version:
 * @Author: Huang
 * @date: 2025-03-25
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService userService;

    @GetMapping("/{id}")
    public UserVo queryUserById(@PathVariable Integer id) {
        return UserMapper.INSTANCE.toUserVo(userService.queryUserById(id));
    }


    @GetMapping("/test/{id}")
    public User queryUserById2(@PathVariable Integer id) {
        return userService.queryUserById(id);
    }
}
